package test.pcs;

import com.payment.lc.limit.service.api.LimitVerifyService;
import com.payment.lc.limit.service.enums.VerifyType;
import com.payment.lc.limit.service.request.VerifyRequest;
import com.payment.lc.limit.service.response.VerifyResponse;
import com.payment.lc.pcs.client.wrap.bo.ProductionPurchaseAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionRedeemAttributes;
import com.payment.lc.pcs.client.wrap.bo.ProductionTimeAttributes;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapService;
import com.payment.lc.pcs.client.wrap.service.ProductionWrapServiceV20;
import com.payment.lc.pcs.common.enums.BizType;
import com.payment.lc.pcs.service.api.*;
import com.payment.lc.pcs.service.bo.ProductionSellDataV2;
import com.payment.lc.pcs.service.bo.ProductionSellInfo;
import com.payment.lc.pcs.service.domain.*;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import test.BaseTest;

import java.util.List;

/**
 * Created on 2016/8/8.
 */
public class Demo1PcsTest5 extends BaseTest {

    @Autowired
    ProductionService productionService;

    @Autowired
    ProductionServiceV20 productionServiceV20;

    @Autowired
    ProductionWrapServiceV20 productionWrapServiceV20;

    @Autowired
    ProductionWrapService productionWrapService;

    @Autowired
    LimitVerifyService limitVerifyServiceClient;

    @Autowired
    DynamicDataService dynamicDataService;

    @Autowired
    MaintainService maintainService;

    @Autowired
    DateTypeService dateTypeService;

    @Test
    public void test() {
        test8();
        test9();
        test4();
    }

    void test9() {
        String prodCode = "MP0002";
        ListWrapper<ProductionLimit> limit = productionService.getLimit(prodCode, BizType.Fundin);
        print(limit);

        ProductionLimit limit1 = limit.getList().get(0);
        List<ProductionLimitFrame> currentLimitFrames = limit1.getCurrentLimitFrames();
        display(currentLimitFrames);

        List<ProductionLimitFrame> usefulLimitFrames = limit1.getUsefulLimitFrames();
        display(usefulLimitFrames);
    }

    void test8() {
        String prodCode = "MP0002";
        Production production = productionWrapService.getProduction(prodCode);
        ProductionSellInfo productionSellInfo = productionWrapService.getProductionSellInfo(prodCode, false);
        display(productionSellInfo);

        ProductionPurchaseAttributes purchaseAttributes = productionWrapService.getProductionPurchaseAttributes(production, false);
        display(purchaseAttributes);

        ProductionSellDataV2 sellDataV2 = dynamicDataService.getProductionSellDataV2(prodCode);
        display(sellDataV2);
    }

    void test7() {
        String prodCode = "MP0002";
        Production production = productionWrapService.getProduction(prodCode);
        ListWrapper<ProductionLimit> limit = productionService.getLimit(prodCode, BizType.Fundin);
        List<ProductionLimit> list = limit.getList();
        ProductionLimit limit1 = list.get(0);
        List<ProductionLimitFrame> currentLimitFrames = limit1.getCurrentLimitFrames();
        display(limit1);
        display(currentLimitFrames);

    }

    void test6() {
        String prodCode = "MP0002";
        Production production = productionWrapService.getProduction(prodCode);
        ProductionSellInfo productionSellInfo = productionWrapService.getProductionSellInfo(prodCode, false);
        display(productionSellInfo);

        ProductionPurchaseAttributes purchaseAttributes = productionWrapService.getProductionPurchaseAttributes(production, false);
        display(purchaseAttributes);
    }

    void test5() {
        String prodCode = "MP0002";
        ProductionSellDataV2 sellDataV2 = dynamicDataService.getProductionSellDataV2(prodCode);
        display(sellDataV2);
    }

    void test4() {
        String prodCode = "MP0002";
        VerifyRequest verifyRequest = new VerifyRequest();
        verifyRequest.setVerifyType(VerifyType.IS_SELLOUT);
        verifyRequest.setProductionCode(prodCode);
        VerifyResponse resp = limitVerifyServiceClient.limitVerify(verifyRequest);
        print(resp);
    }

    void test3() {
        String prodCode = "SF3508";
        Production production = productionWrapService.getProduction(prodCode);
        ProductionTimeAttributes timeAttributes = productionWrapService.getProductionTimeAttributes(production, false);
        print(timeAttributes);
        ProductionRedeemAttributes redeemAttributes = productionWrapService.getProductionRedeemAttributes(production, false);
        print(redeemAttributes);
    }

}